<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
	    <!-- Loading Bootstrap -->
	    <link href="./Public/Adminstyle/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
	    <!-- Loading Flat UI -->
	    <link href="./Public/Adminstyle/Flat/dist/css/flat-ui.css" rel="stylesheet">
	    <link href="./Public/Adminstyle/Flat/docs/assets/css/demo.css" rel="stylesheet">
	    <link rel="shortcut icon" href="./Public/Adminstyle/Flat/img/favicon.ico">
	    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
	    <!--[if lt IE 9]>
	      <script src="dist/js/vendor/html5shiv.js"></script>
	      <script src="dist/js/vendor/respond.min.js"></script>
	    <![endif]-->
	    <script type="text/javascript" src="./Public/jquery-1.7.2.min.js"></script>
	    <script type="text/javascript">
	    	$(function(){
	    		$(".fenlei").change(function(){
	    			$('.guige tr').remove();
	    			$('.shuxing tr').remove();
	    			var cid = $(this).val();//获得value
	    			//alert(data);
	    			$.ajax({
	    				//请求方式
	    				type:"post",
	    				//请求地址
	    				url:"<?php echo U('Ajax/index')?>",
	    				//请求数据
	    				data:{cids:cid},
	    				//返回类型
	    				dataType:"json",
	    				//成功后处理
	    				success:function(phpData){
	    					if(!phpData) return;
	    					$(phpData).each(function(k,v){
	    						var str='';
	    						if(v.aclass==0){
	    							//str += '<input type="hidden" name="suid[]"  value="' + v.suid + '" />';
	    							str += '<tr><td width="200px">'+v.aname+'<input type="hidden" name="suid[]"  value="' + v.suid + '" /></td>';
	    							str += '<td width="500px"><select name="att_value[]" class="form-control">';
	    							for(var j=0,m=v.attr.length;j<m;j++){
	    							str += '<option value="'+v.attr[j]+'">'+ v.attr[j]+'</option>';
	    							}
	    							$('.guige').append(str);
	    						}else{
	    							//str += '<input type="hidden" name="suid"  value="' + v.suid + '" />';
	    							str += '<tr><td width="200px">'+v.aname+'<input type="hidden" name="suid[]"  value="' + v.suid + '" /></td>';
	    							str += '<td width="500px"><select name="att_value[]" class="form-control">';
	    							for(var j=0,m=v.attr.length;j<m;j++){
	    							str += '<option value="'+v.attr[j]+'">'+ v.attr[j]+'</option>';
	    							}
	    							$('.shuxing').append(str);
	    						}
	    					})
	    					
	    				}
	    			})
	    			/*$.post("请求地址","{参数}",function(){
	    				
	    			},"json")*/
	    		});
	    	})
	    	
	    </script>
	</head>
	<body>
		
		<div class="alert alert-success">添加商品</div>
		<form action="" method="post" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleInputEmail1">商品名称</label>
			<input id="exampleInputEmail1" class="form-control" type="text"  name="com_name">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">所属分类</label>
			<select name="category_cid" class="form-control fenlei" >
				<option  value="0">请选择</option>
				<?php foreach ($AllCate as $k=>$v){?>
				<option class="fenlei" value="<?php echo $v['cid']?>"><?php echo $v['_cname']?></option>
				<?php }?>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">所属品牌</label>
			<select name="brand_bid" class="form-control">
				<?php foreach ($AllBrand as $k=>$v){?>
				<option value="<?php echo $v['bid']?>"><?php echo $v['bname']?></option>
				<?php }?>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">库存</label>
			<input id="exampleInputEmail1" class="form-control" type="text"   name="stock" >
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">单位</label>
			<input id="exampleInputEmail1" class="form-control" type="text"  name="com_unit" >
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">原件</label>
			<input id="exampleInputEmail1" class="form-control" type="text"  name="oldprice">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">现价</label>
			<input id="exampleInputEmail1" class="form-control" type="text"  name="nowprice">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">商品规格</label>
			<table class="guige">
				
			</table>
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">商品属性</label>
			<table class="shuxing">
				
			</table>
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">商品图片</label>
			<input type="file" name="thumb" id="" value="" />
		</div>
		<!--编辑器-->
			<script type="text/javascript" src="Public/ueditor1_4_3/ueditor.config.js"></script>
			<script type="text/javascript" src="Public/ueditor1_4_3/ueditor.all.min.js"></script>
			<script type="text/javascript" src="Public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
			
			<div class="form-group">
				<label for="exampleInputEmail1">内容</label>
				<script id="editor" type="text/javascript" name="content" style="width: 100%;height: 200px;"></script>
				<script type="text/javascript">
					var ue = UE.getEditor("editor");
				</script>	
			</div>
		<button class="btn btn-primary btn-block" type="submit"> 确定 </button>
		</form>
	</body>
</html>
